/*
非ChenHacker不得编辑
*/
#include<bits/stdc++.h>
#include"gb.h"
using namespace std;
class Screen {
public:
	int MaxN;//最大行数
	int MaxM;//最大列数
	char pm[30][120];
	char pm_old[30][120];
	Screen();
	int SetScreen(char SetData,int i,int j);
	int show();//刷新
	int cls();//清屏
	int add(char* Data,int x,int y,int n,int m);
};
Screen::Screen() {
	HANDLE handle = GetStdHandle(STD_OUTPUT_HANDLE);
	CONSOLE_CURSOR_INFO CursorInfo;
	GetConsoleCursorInfo(handle, &CursorInfo);//获取控制台光标信息
	CursorInfo.bVisible = false; //隐藏控制台光标
	SetConsoleCursorInfo(handle, &CursorInfo);//设置控制台光标状态
	MaxN=30;
	MaxM=120;
	memset(pm,0,sizeof(pm));
	memset(pm_old,0,sizeof(pm_old));
}
int Screen::SetScreen(char SetData,int i,int j) {
	pm_old[i][j]=pm[i][j]=SetData;
	move_gb(i,j);
	putchar(SetData);
	return 0;
}
int Screen::show() {
	for(int i=0;i<MaxN;i++) {
		for(int j=0;j<MaxM;j++) {
			if(pm[i][j]!=pm_old[i][j]) {
				SetScreen(pm[i][j],i,j);
			}
		}
	}
	move_gb(0,0);
	return 0;
}
int Screen::cls() {
	memset(pm,0,sizeof(pm));
	return 0;
}
int Screen::add(char* Data,int x,int y,int n,int m) {
	int k=0;
 	for(int i=0;i<n;i++) {
		for(int j=0;j<m;j++,k++) {
			if(Data[k]!='\0'&&i+x<MaxN&&i+x>=0&&y+j<MaxM&&y+i>=0) 
				pm[i+x][j+y]=Data[k];
		}
	}
	return 0;
}